<?php

	namespace Vavilen\FirstBundle\Entity;

	use Doctrine\ORM\Mapping as ORM;
	use Doctrine\Common\Collections\ArrayCollection;
	use Gedmo\Mapping\Annotation as Gedmo;

	/**
	 * @Gedmo\Tree(type="nested")
	 * @ORM\Entity(repositoryClass="Vavilen\FirstBundle\Entity\Repository\CategoryRepository")
	 * @ORM\Table(name="category")
	 */
	class Category
	{

		/**
		 * @var integer $id
		 *
		 * @ORM\id
		 * @ORM\Column(name="id", type="integer")
		 * @ORM\GeneratedValue(strategy="AUTO")
		 */
		protected $id;

		/**
		 * @var string $title
		 *
		 * @ORM\Column(name="category_name", type="string", length=255, unique=true)
		 */
		protected $categoryName;

		/**
		 * @var string $title
		 *
		 * @ORM\Column(name="url", type="string", length=255, unique=true)
		 */
		protected $url;

		/**
		 * @Gedmo\TreeLeft
		 * @ORM\Column(name="lft", type="integer")
		 */
		protected $lft;

		/**
		 * @Gedmo\TreeLevel
		 * @ORM\Column(name="lvl", type="integer")
		 */
		protected $lvl;

		/**
		 * @Gedmo\TreeRight
		 * @ORM\Column(name="rgt", type="integer")
		 */
		protected $rgt;

		/**
		 * @Gedmo\TreeRoot
		 * @ORM\Column(name="root", type="integer", nullable=true)
		 */
		protected $root;

		/**
		 * @ORM\OneToMany(targetEntity="\Vavilen\FirstBundle\Entity\Category", mappedBy="parentCategory")
		 * @ORM\OrderBy({"lft" = "ASC"})
		 */
		protected $children;

		/**
		 * @var int $parentCategoryId
		 *
		 * @ORM\ManyToOne(targetEntity="\Vavilen\FirstBundle\Entity\Category", inversedBy="children")
		 * @ORM\JoinColumn(name="parent_category_id", referencedColumnName="id", nullable=true)
		 */
		protected $parentCategory;

		/**
		 * @ORM\OneToMany(targetEntity="\Vavilen\FirstBundle\Entity\Post", mappedBy="category")
		 */
		protected $posts;
	    /**
     * Constructor
     */
    public function __construct()
    {
        $this->children = new \Doctrine\Common\Collections\ArrayCollection();
        $this->posts = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set categoryName
     *
     * @param string $categoryName
     * @return Category
     */
    public function setCategoryName($categoryName)
    {
        $this->categoryName = $categoryName;
    
        return $this;
    }

    /**
     * Get categoryName
     *
     * @return string 
     */
    public function getCategoryName()
    {
        return $this->categoryName;
    }

    /**
     * Set url
     *
     * @param string $url
     * @return Category
     */
    public function setUrl($url)
    {
        $this->url = $url;
    
        return $this;
    }

    /**
     * Get url
     *
     * @return string 
     */
    public function getUrl()
    {
        return $this->url;
    }

    /**
     * Set lft
     *
     * @param integer $lft
     * @return Category
     */
    public function setLft($lft)
    {
        $this->lft = $lft;
    
        return $this;
    }

    /**
     * Get lft
     *
     * @return integer 
     */
    public function getLft()
    {
        return $this->lft;
    }

    /**
     * Set lvl
     *
     * @param integer $lvl
     * @return Category
     */
    public function setLvl($lvl)
    {
        $this->lvl = $lvl;
    
        return $this;
    }

    /**
     * Get lvl
     *
     * @return integer 
     */
    public function getLvl()
    {
        return $this->lvl;
    }

    /**
     * Set rgt
     *
     * @param integer $rgt
     * @return Category
     */
    public function setRgt($rgt)
    {
        $this->rgt = $rgt;
    
        return $this;
    }

    /**
     * Get rgt
     *
     * @return integer 
     */
    public function getRgt()
    {
        return $this->rgt;
    }

    /**
     * Set root
     *
     * @param integer $root
     * @return Category
     */
    public function setRoot($root)
    {
        $this->root = $root;
    
        return $this;
    }

    /**
     * Get root
     *
     * @return integer 
     */
    public function getRoot()
    {
        return $this->root;
    }

    /**
     * Add children
     *
     * @param \Vavilen\FirstBundle\Entity\Category $children
     * @return Category
     */
    public function addChildren(\Vavilen\FirstBundle\Entity\Category $children)
    {
        $this->children[] = $children;
    
        return $this;
    }

    /**
     * Remove children
     *
     * @param \Vavilen\FirstBundle\Entity\Category $children
     */
    public function removeChildren(\Vavilen\FirstBundle\Entity\Category $children)
    {
        $this->children->removeElement($children);
    }

    /**
     * Get children
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getChildren()
    {
        return $this->children;
    }

    /**
     * Set parentCategory
     *
     * @param \Vavilen\FirstBundle\Entity\Category $parentCategory
     * @return Category
     */
    public function setParentCategory(\Vavilen\FirstBundle\Entity\Category $parentCategory = null)
    {
        $this->parentCategory = $parentCategory;
    
        return $this;
    }

    /**
     * Get parentCategory
     *
     * @return \Vavilen\FirstBundle\Entity\Category 
     */
    public function getParentCategory()
    {
        return $this->parentCategory;
    }

    /**
     * Add posts
     *
     * @param \Vavilen\FirstBundle\Entity\Post $posts
     * @return Category
     */
    public function addPost(\Vavilen\FirstBundle\Entity\Post $posts)
    {
        $this->posts[] = $posts;
    
        return $this;
    }

    /**
     * Remove posts
     *
     * @param \Vavilen\FirstBundle\Entity\Post $posts
     */
    public function removePost(\Vavilen\FirstBundle\Entity\Post $posts)
    {
        $this->posts->removeElement($posts);
    }

    /**
     * Get posts
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getPosts()
    {
        return $this->posts;
    }
}